<template>
  <div class="page-header" :class="{ 'page-header-compact': compact }">
    <div class="page-header-content">
      <div class="page-header-left">
        <el-icon v-if="icon" class="page-header-icon" :size="iconSize">
          <component :is="icon" />
        </el-icon>
        <div class="page-header-text">
          <h1 class="page-title">{{ title }}</h1>
          <p v-if="subtitle" class="page-subtitle">{{ subtitle }}</p>
        </div>
      </div>
      <div v-if="$slots.actions" class="page-header-right">
        <slot name="actions"></slot>
      </div>
    </div>
    <div v-if="$slots.extra" class="page-header-extra">
      <slot name="extra"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PageHeader',
  props: {
    title: {
      type: String,
      required: true,
    },
    subtitle: {
      type: String,
      default: '',
    },
    icon: {
      type: [String, Object],
      default: null,
    },
    iconSize: {
      type: [Number, String],
      default: 28,
    },
    compact: {
      type: Boolean,
      default: false,
    },
  },
}
</script>

<style scoped>
.page-header {
  margin-bottom: var(--spacing-lg, 24px);
  padding: var(--spacing-lg, 24px);
  background: var(--gradient-card, linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(227,242,253,0.8) 100%));
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(200, 16, 46, 0.12));
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.page-header:hover {
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(200, 16, 46, 0.16));
}

.page-header-compact {
  padding: var(--spacing-md, 16px);
  margin-bottom: var(--spacing-md, 16px);
}

.page-header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-md, 16px);
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-md, 16px);
  flex: 1;
}

.page-header-icon {
  color: var(--nanchang-red, #C8102E);
  flex-shrink: 0;
}

.page-header-text {
  flex: 1;
}

.page-title {
  margin: 0;
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 600;
  color: var(--text-primary, #303133);
  line-height: 1.4;
}

.page-subtitle {
  margin: var(--spacing-xs, 4px) 0 0 0;
  font-size: clamp(13px, 2vw, 16px);
  color: var(--text-secondary, #606266);
  line-height: 1.5;
}

.page-header-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm, 8px);
  flex-shrink: 0;
}

.page-header-extra {
  margin-top: var(--spacing-md, 16px);
  padding-top: var(--spacing-md, 16px);
  border-top: 1px solid rgba(200, 16, 46, 0.1);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    padding: var(--spacing-md, 16px);
  }

  .page-header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header-right {
    width: 100%;
    justify-content: flex-end;
  }

  .page-title {
    font-size: 20px;
  }

  .page-subtitle {
    font-size: 14px;
  }
}
</style>


